<template>
    <div v-if="left">
<!--      <div style="width: 1139px">-->
      <div>
        <el-form :model="form" :inline="inline" :label-width="labelWidth ?( labelWidth +'px') :  '60px'" label-position="left">
          <slot :form="form"/>
          <el-form-item v-if="showSearchButton || showAddButton || url" >
            <el-button v-if="showSearchButton && queryButton" size="small" round type="primary" @click="handleSearch">查询</el-button>
            <el-button v-if="showSearchEnter" size="small" round type="primary" @click="onSubmit">确定</el-button>
            <el-button v-if="showAddButton && addButton" size="small" round type="primary" @click="handleDataInsert">新增</el-button>
            <el-button v-if="showSuccessOrderList" size="small" round type="primary" @click="successOrderList">批量成功</el-button>
            <el-button v-if="showFailtOrderList" size="small" round type="primary" @click="failtOrderList">批量失败</el-button>
            <el-button v-if="showbatchHandleOpen" size="small" round type="primary" @click="batchHandleOpen">批量开启</el-button>
            <el-button v-if="showbatchHandleClose" size="small" type="primary" round @click="batchHandleClose">批量关闭</el-button>
            <el-button v-if="showHandleBatchEdit" size="small" type="primary" round @click="handleBatchEdit">批量修改</el-button>
            <el-button v-if="showExportDataButton" type="primary" size="small" round @click="exportData">导出</el-button>
            <el-button v-if="showMinuteHandleSearch" type="primary" size="small" round @click="minuteHandleSearch">3分钟未回调的</el-button>
            <el-button v-if="showStatusCallBacks"  type="primary" size="small" round @click="statusCallBacks">批量回调</el-button>
            <el-button v-if="showRepeatFlowOrder"  type="primary" size="small" round @click="repeatFlowOrder">批量重提</el-button>
            <el-button v-if="showGenerateBill" size="small" round type="primary" @click="generateBill">生成对账单</el-button>
            <el-button v-if="showShopBatchEdit" size="small" round type="primary" @click="handleShopBatchEdit">商户批量</el-button>
            <el-button v-if="showDiscountBatch" size="small" round type="primary" @click="discountBatch">折扣批量</el-button>
            <el-button v-if="showHandleBatchUpProduct" size="small" round type="primary" @click="handleBatchUpProduct">批量匹配产品</el-button>
            <el-button v-if="showHandleBatchAuto" size="small" round type="primary" @click="handleBatchAuto">批量自动产品</el-button>
            <el-button v-if="showHandleBatchOpen" size="small" round type="primary" @click="handleBatchOpen">批量开启产品</el-button>
            <el-button v-if="showHandleBatchClose" size="small" round type="primary" @click="handleBatchClose">批量禁用产品</el-button>
            <el-button v-if="showTimerPrice" size="small" round type="primary" @click="timerPrice">定时调价</el-button>
            <el-button v-if="showCopyProduct" size="small" round type="primary" @click="copyProduct">复制产品</el-button>
            <el-button v-if="showRepeatOrderStatus" size="small" round type="primary" @click="repeatOrderStatus">订单重置</el-button>
            <el-button v-if="url" size="small" round type="primary" @click="importClick">导入</el-button>
            <el-button v-if="exportStock" size="small" round type="primary" @click="exportStock">出库</el-button>
            <el-button v-if="batchDelete" size="small" round type="primary" @click="batchDelete">批量删除</el-button>
          </el-form-item>
        </el-form>
      </div>
    </div>
    <div  v-else >
      <div>
        <el-form :model="form" :inline="inline" :label-width="labelWidth ?( labelWidth +'px') :  '73px'" label-position="left">
          <slot :form="form"/>
          <el-form-item v-if="showSearchButton || showAddButton || url" >
            <el-button v-if="showSearchButton && queryButton" size="small" round type="primary" @click="handleSearch">查询</el-button>
            <el-button v-if="showAddButton && addButton" size="small" round type="primary" @click="handleDataInsert">新增</el-button>
<!--            <el-button v-if="showSuccessOrderList" size="small" round type="primary" @click="handleSend">发送通知</el-button>-->
            <el-upload v-if="url" class="inline-block" :action="url">
              <el-button size="small" round type="primary">导入</el-button>
            </el-upload>
          </el-form-item>
        </el-form>
      </div>
    </div>

</template>
<script>
export default {
  name: 'SerachPanel',
  props: {
    showSearchButton: { type: Boolean, default: true },
    queryButton: { type: Boolean, default: true },//权限
    addButton: { type: Boolean, default: true },//权限
    showAddButton: { type: Boolean, default: true },
    url: { type: String, default: '' },
    showSuccessOrderList: { type: Boolean, default: false },
    showFailtOrderList: { type: Boolean, default: false },
    showSearchEnter: { type: Boolean, default: false },//确认按钮默认隐藏
    showbatchHandleOpen: { type: Boolean, default: false },
    showbatchHandleClose: { type: Boolean, default: false },
    showExportDataButton: { type: Boolean, default: false },
    showHandleBatchEdit: { type: Boolean, default: false },
    showGenerateBill: { type: Boolean, default: false },
    showShopBatchEdit: { type: Boolean, default: false },
    showDiscountBatch: { type: Boolean, default: false },
    showHandleBatchUpProduct: { type: Boolean, default: false },
    showHandleBatchAuto: { type: Boolean, default: false },
    showHandleBatchOpen: { type: Boolean, default: false },
    showHandleBatchClose: { type: Boolean, default: false },
    showTimerPrice: { type: Boolean, default: false },
    showCopyProduct: { type: Boolean, default: false },
    showStatusCallBacks: { type: Boolean, default: false },
    showMinuteHandleSearch: { type: Boolean, default: false },
    showRepeatFlowOrder:{ type: Boolean, default: false },
    showRepeatOrderStatus: { type: Boolean, default: false },
    // form label 默认宽度
    labelWidth: { type: String, default: '73' },
    left: { type: Boolean, default:true },
    //默认是否显示查询按钮
//    defaultShow: { type: Boolean, default: true },
  },
  data() {
    return {
      inline: true,
      form: {}
    }
  },
  methods: {
    handleSearch() {
      this.$emit('search', this.form);
    },
    handleDataInsert() {
      this.$emit('insert');
    },
    handleSend() {
      this.$emit('send');
    },
    onSubmit(){
      this.$emit('onSubmit');
    },
    batchHandleOpen(){
      this.$emit('batchHandleOpen');
    },
    batchHandleClose(){
      this.$emit('batchHandleClose');
    },
    exportData(){
      this.$emit('exportData');
    },
    handleBatchEdit(){
      this.$emit('handleBatchEdit');
    },
    successOrderList(){
      this.$emit('successOrderList');
    },
    failtOrderList(){
      this.$emit('failtOrderList');
    },
    generateBill(){
      this.$emit('generateBill');
    },
    handleShopBatchEdit(){
      this.$emit('handleShopBatchEdit');
    },
    discountBatch(){
      this.$emit('discountBatch');
    },
    handleBatchUpProduct(){
      this.$emit('handleBatchUpProduct');
    },
    handleBatchAuto(){
      this.$emit("handleBatchAuto");
    },
    handleBatchOpen(){
      this.$emit("handleBatchOpen");
    },
    handleBatchClose(){
      this.$emit("handleBatchClose");
    },
    timerPrice(){
      this.$emit("timerPrice");
    },
    copyProduct(){
      this.$emit("copyProduct");
    },
    statusCallBacks(){
      this.$emit("statusCallBacks");
    },
    minuteHandleSearch(){
      this.$emit("minuteHandleSearch");
    },
    repeatFlowOrder(){
      this.$emit("repeatFlowOrder");
    },
    repeatOrderStatus(){
      this.$emit("repeatOrderStatus");
    },
    importClick() {
      this.$emit("importClick");
    },
    exportStock() {
      this.$emit("exportStock");
    },
    batchDelete(){
      this.$emit("batchDelete");
    }
  }
}
</script>
<style lang="scss" scoped>
.inline-block {
  display: inline-block;
  margin-left: 10px;
}

</style>
